import request from '@/utils/request'

// 获取员工的简单列表
export function getEmployeeSimple() {
  return request.get('/sys/user/simple')
}

/**
* @description: 获取员工列表
* @param {object} page 页码 size 数量
* @return: Object
*/
export const getEmployeeList = params => {
  return request.get('/sys/user', { params })
}

/**
* @description: 删除员工
* @param {string} id 被删除的员工id
*/
export const delEmployee = id => {
  return request.delete(`/sys/user/${id}`)
}

/**
* @description:新增-员工
* @param {Object} data 员工信息
*/
export const addEmployee = data => {
  return request.post('/sys/user', data)
}

/**
* @description:  员工导入
* @param {object}  data 员工数据
*/
export const importEmployee = data => {
  return request.post('/sys/user/batch', data)
}

// 读取个人详情的基础信息（下面）
export const getPersonalDetail = id => {
  return request.get(`/employees/${id}/personalInfo`)
}

// 更新个人详情的基础信息（下面）
export const updatePersonal = data => {
  return request.put(`/employees/${data.userId}/personalInfo`, data)
}

// 获取岗位信息
export const getJobDetail = id => {
  return request.get(`/employees/${id}/jobs`)
}

// 更新岗位信息
export const updateJob = data => {
  return request.put(`/employees/${data.userId}/jobs`, data)
}

// 保存员工的基本信息
export const saveUserDetailById = data => {
  return request.put(`/sys/user/${data.id}`, data)
}

// 给用户分配角色
export const assignRoles = data => {
  return request.put('/sys/user/assignRoles', data)
}
